import React from 'react';

import {connect} from 'dva'
import { HotlineAbstract } from 'components/Abstract'
import Title from 'components/Title'

@connect(({hotline}) => ({...hotline}))
class Indicators extends React.Component {
    static defaultProps = {
        abstractist: [
          { label: '客服热线', field: 'total', icon: 'kefu' },
          { label: '维修工单', field: 'wxgd', icon: 'tools' },
          { label: '完结工单', field: 'connect', icon: 'success' },
          { label: '用户咨询', field: 'yhzx', icon: 'msg1' },
          { label: '用户投诉', field: 'yfts', icon: 'complaint1' },
        ]
    }

  componentDidMount() {
    this.init();
  }

  init = async () => {
    await this.setDateIndicators()
  }

  // 获取指标
  setDateIndicators = async () => {
    await this.props.dispatch({
      type: 'hotline/queryIndicators'
    });
  }
  
  // 指标渲染
  render() {
    const { abstractist, IndicatorsResource: dataSource } = this.props;
    return (
      <Title title={'重点指标监控'}  style={{'paddingLeft': '4%', 'paddingRight': '4%'}}>
        <HotlineAbstract
          columns={abstractist}
          dataSource={dataSource}
          className={'col-12'}/>
      </Title>
    )
  }
}

export default Indicators;
